package com.chixing.ih.module.programmer.service.Impl;

import com.chixing.ih.module.programmer.mapper.WorkExperMapper;
import com.chixing.ih.module.programmer.pojo.WorkExper;
import com.chixing.ih.module.programmer.service.IWorkExperService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 *
 * @version 1.0
 * @Author MasterYan
 * @Date 2020/10/3
 * Time: 1:33
 */
@Service
@Transactional
public class WorkExperServiceImpl implements IWorkExperService {

    @Autowired
    WorkExperMapper workExperMapper;

    @Override
    public boolean updateList(List<WorkExper> workExpers) {
        for (WorkExper workExper : workExpers
        ) {
            int record = workExperMapper.updateOne(workExper);
            if (record == 0)
                return false;
        }
        return true;

    }

    @Override
    public List<WorkExper> listAll(long userId) {
        List<WorkExper> workExpers = workExperMapper.listAll(userId);
        return workExpers;
    }

    @Override
    public WorkExper saveList(WorkExper workExper) {
        int record = workExperMapper.insertOne(workExper);
        if (record > 0)
            return workExper;
        return null;

    }

    @Override
    public boolean deleteWorkExper(long id) {
        int record = workExperMapper.deleteOne(id);
        if (record == 0)
            return false;

        return true;
    }
}
